﻿using System;
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Entities;

namespace TestCluster.usermodels
{
    /// <summary>
    /// 用户信息
    /// </summary>
    [Comment("登录用户表")]
    [Index(nameof(Email), IsUnique = true)]
    public class UserInfo : Entity<int>
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [MaxLength(32)]
        public string UserName { get; set; }

        /// <summary>
        /// 用户头像
        /// </summary>
        [MaxLength(128)]
        public string UserHead { get; set; }

        /// <summary>
        /// 创建日期
        /// </summary>
        public DateTime CreateDate { get; set; } = DateTime.Now;

        /// <summary>
        /// 描述
        /// </summary>
        [MaxLength(64)]
        public string Desc { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        [MaxLength(64)]
        public string Email { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [MaxLength(64)]
        public string PassWord { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public bool IsEnable { get; set; } = true;

        /// <summary>
        /// 哪个角色？
        /// </summary>
        [MaxLength(16)]
        public string Grade { get; set; }

        /// <summary>
        /// 角色ID
        /// </summary>
        [Comment("角色ID")]
        public int GradeId { get; set; } = 0;
    }

    /// <summary>
    /// 权限列表
    /// </summary>
    public class RoleInfo : Entity<int>
    {

        /// <summary>
        /// 权限模块
        /// </summary>
        [MaxLength(16)]
        public string Model { get; set; }

        /// <summary>
        /// 权限项
        /// </summary>
        [MaxLength(16)]
        public string Name { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [MaxLength(64)]
        public string Desc { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public bool IsEnable { get; set; } = true;

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; } = 100;

        /// <summary>
        /// 父级的概念
        /// </summary>
        public int FatherId { get; set; }

        /// <summary>
        /// 层级
        /// </summary>
        public int Level { get; set; }
    }


    /// <summary>
    /// 角色分组
    /// </summary>
    [Index(nameof(Name), IsUnique = true)]
    public class GradeInfo : Entity<int>
    {
        /// <summary>
        /// 角色分组名称
        /// </summary>
        [MaxLength(16)]
        public string Name { get; set; }

        /// <summary>
        /// 分组描述
        /// </summary>
        [MaxLength(64)]
        public string Desc { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public bool IsEnable { get; set; } = true;

    }

    /// <summary>
    /// 角色绑定权限
    /// </summary>
    [Comment("角色绑定权限")]
    public class GradeRole : Entity<int>
    {
        /// <summary>
        /// 组别ID
        /// </summary>
        public int GradeId { get; set; }

        /// <summary>
        /// 权限ID
        /// </summary>
        public int RoleId { get; set; }
    }

    /// <summary>
    /// 部门信息 人员组，前端开发组，后端开发组，测试组，设计组，产品组等
    /// </summary>
    [Comment("部门信息")]
    public class PartInfo : Entity<int>
    {
        /// <summary>
        /// 名称
        /// </summary>
        [MaxLength(16)]
        [Comment("名称")]
        public string Name { get; set; }

        /// <summary>
        /// 短名称
        /// </summary>
        [MaxLength(8)]
        [Comment("短名称")]
        public string ShortName { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [MaxLength(32)]
        [Comment("描述")]
        public string Desc { get; set; }

        /// <summary>
        /// 父级ID
        /// </summary>
        [Comment("父级ID")]
        public int FatherId { get; set; }

        /// <summary>
        /// 转发中显示此按钮
        /// </summary>
        [Comment("显示转发按钮")]
        public bool ShowButton { get; set; } = true;

        /// <summary>
        /// 层级链 x,x,x,x, 包含自己
        /// </summary>
        public string FatherStr { get; set; }

        /// <summary>
        /// 层级深度，用于样式
        /// </summary>
        public int Level { get; set; } = 0;

        //某人属于某一个部门组，未必在某一个项目中有他，需要他参与了这个项目，才能在这个项目中选定这个组里面有他.
    }

    /// <summary>
    /// 用户绑定部门 一个人可以属于多个部门
    /// </summary>
    [Comment("用户绑定部门")]
    public class BindUserPart : Entity<int>
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        [Comment("用户ID")]
        public int UserId { get; set; }

        /// <summary>
        /// 部门ID
        /// </summary>
        [Comment("部门ID")]
        public int PartId { get; set; }
    }
}
